import { Suspense } from "react";
import routes from "./routes";
const routeMap = (routes: any[]) => {
  return routes.map((route) => {
    const path = route.path;
    const element = <Suspense fallback={<Loading />}>{route.element}</Suspense>;
    const key = route.path;
    return !route?.children?.length ? (
      <Route path={path} element={element} key={key} />
    ) : (
      <Route path={path} element={element} key={key}>
        {routeMap(route.children)}
      </Route>
    );
  });
};
function App() {
  return (
    <>
      <Routes>{routeMap(routes)}</Routes>
    </>
  );
}

export default App;
